import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.3

Window {
    id: lockWnd
    title: "风险管理锁屏"
    visible: false
    maximumWidth: 300
    maximumHeight: 100
    minimumHeight: 120
    minimumWidth: 300

    ColumnLayout {
        anchors.fill: parent
        spacing: 5
        RowLayout {
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.top: parent.top
            anchors.topMargin: 40
            anchors.right: parent.right
            anchors.rightMargin: 10
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 60
            spacing: 3
            Text {
                text: qsTr("密码：")
                //                Layout.alignment: Qt.AlignRight
                anchors.left: parent.left
                anchors.leftMargin: 20
                font.pixelSize: 16
            }

            TextField {
                id: inputName
                anchors.right: parent.right
                anchors.rightMargin: 70
                echoMode: TextInput.Password
            }

            Text {
                id: tipErr
                text: qsTr("密码错误")
                anchors.right: parent.right
                anchors.rightMargin: 3
                font.pixelSize: 14
                color: "red"
                visible: false
            }
        }

        RowLayout {
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 20
            anchors.right: parent.right
            anchors.rightMargin: 10
            Button {
                text: qsTr("确定")
                anchors.left: parent.left
                anchors.leftMargin: 30
                onClicked: {
                    if (g_MainQuo.checkPassword(inputName.text)) {
                        root.show()
                        lockWnd.close()
                    } else
                        tipErr.visible = true
                }
            }

            Button {
                text: qsTr("退出")
                anchors.right: parent.right
                anchors.rightMargin: 30
                onClicked: Qt.quit()
            }
        }
    }

    //    MessageDialog {   //会导致程序退出
    //        id: errMsgbox
    //        standardButtons: StandardButton.Cancel
    //        //        modality: Qt.
    //        title: "提示"
    //        text: "密码错误"
    //        onYes: {
    //            //            errMsgbox.close()
    //            console.log("errMsgbox click ok ")
    //        }
    //    }
}
